package com.re6g3y.game.Tile.Hexagonal.mapGenerate;

import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.math.Vector2;
import com.re6g3y.game.Tile.Hexagonal.HexagonalIterator;
import com.re6g3y.game.Tile.Hexagonal.HexagonalTile;
import com.re6g3y.game.Tile.Hexagonal.QueryCallback;
import com.re6g3y.game.core.GameCore;

//
public class HexagonalChunk {
    public HexagonalTile hexagonalTiles[];
    public static final int chunkSize=5;//range 0-5;
    public static final int scl=20;//range 0-5;
    public HexagonalChunk(final Vector2 center){
        int k=chunkSize*(chunkSize+1);
        hexagonalTiles=new HexagonalTile[k*k];

        GameCore.getInstance().map.queryByPointAndRange(Vector2.Zero, new QueryCallback() {
            int ind=0;
            @Override
            public boolean Callback(HexagonalIterator iterator) {
                HexagonalTile tile=new HexagonalTile(center.x*11.27f*scl+iterator.getPositionCenterX()*scl,center.y*11.27f*scl+iterator.getPositionCenterY()*scl,iterator.getVal(),scl);
                tile.property = GenerateChunk.getTileHeight(center.x*11.27f*scl+iterator.getPositionCenterX()*scl,center.y*11.27f*scl+iterator.getPositionCenterY()*scl, 30);
                HexagonalMapEditor.drawColor(tile);
                hexagonalTiles[ind++]=tile;
                return false;
            }
        },0,6);
    }

    public void draw(Batch batch){
        for(int i=0;i<hexagonalTiles.length;i++){
            if(hexagonalTiles[i]!=null)hexagonalTiles[i].draw(batch);
        }
    }

}
